#include<bits/stdc++.h>
using namespace std;
int n=0;
int r[100005];
int ans=0;
int flg[100005];
int px[100005];
int a[100005];
int cnt=1,hd=1;
priority_queue<int,vector<int>,greater<int>> pq,z;
int main(){
freopen("duel.in","r",stdin);
freopen("duel.out","w",stdout);
cin>>n;
for(int i=0;i<n;i++){
    cin>>r[i];
    pq.push(r[i]);
    z.push(r[i]);
flg[i]=0;

}
for(int i=0;i<n;i++){
    px[i]=z.top();
    z.pop();
}

for(int i=1;i<n;i++){
       if(pq.top()<px[i]&&flg[i-1]==0){
        pq.pop();
        flg[i-1]=1;
        if(a[cnt]>=pq.top())
        {a[cnt]=pq.top();
        cnt++;}
        pq.pop();
        pq.push(a[hd]);
        hd++;
        ans++;
        continue;
       }
       a[cnt]=pq.top();
       cnt++;
       pq.pop();


    }
    cout<<n-ans;

return 0;
}
